//trait特性练习

//定义一个结构体：圆
struct Circle {
    //半径
    redius: f64,
}
//定义trait shape
trait Shape {
    fn area(&self) -> f64;
}

//实现trait中的方法
impl Shape for Circle {
    fn area(&self) -> f64 {
        std::f64::consts::PI * self.redius * self.redius
    }
}
impl Circle {
    fn area2(&self) -> f64 {
        std::f64::consts::PI * self.redius * self.redius
    }
}

fn main() {
    let redius = 2f64;
    let circle = Circle { redius: redius };
    println!("半径为:{}的面积是：{}", redius, circle.area());
    println!("半径为:{}的面积是：{}", redius, circle.area2());
}
